package company.duxiaoman;

import java.util.HashMap;
import java.util.Scanner;

public class Du1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String colors = sc.nextLine();
        String target = sc.nextLine();
        HashMap<Character, Integer> dict = new HashMap<>();
        int colorsLength = colors.length();
        for (int i = 0; i < colorsLength; i++) {
            char color = colors.charAt(i);
            dict.put(color, dict.getOrDefault(color, 0) + 1);
        }
        int ans = 0;
        int targetLength = target.length();
        for (int i = 0; i < targetLength; i++) {
            char c = target.charAt(i);
            if (dict.containsKey(c) && dict.get(c) > 0) {
                ans++;
                dict.put(c, dict.get(c) - 1);
            }
        }
        System.out.println(ans);
    }
}
